/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JFrameNovoFuncionario.java
 *
 * Created on 25/11/2011, 19:53:22
 */
package gui.pessoa;

import banco.pessoa.BancoFuncionario;
import excecoes.estoque.DinheiroNegativoException;
import excecoes.pessoa.CpfCnpjExistenteException;
import excecoes.pessoa.CpfCnpjInvalidoException;
import excecoes.pessoa.LocalizacaoInvalidaException;
import excecoes.pessoa.NomeInvalidoException;
import gui.estoque.JFrameTableEstoque;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import smartMarket.pessoa.Funcionario;

/**
 *
 * @author dyego
 */
public class JFrameNovoFuncionario extends javax.swing.JFrame {

    // Atributos
    private Funcionario funcionario;
    private String acao;
    private Integer linhaSelecionada = null;

    // Construtor
    public JFrameNovoFuncionario() {
        initFuncionario();
        this.acao = "cadastrar";
    }

    public JFrameNovoFuncionario(String cpf, int linha) {
        initFuncionario(cpf);
        this.acao = "alterar";
        this.linhaSelecionada = linha;
    }

    public Funcionario getTextField() {

        try {

            this.funcionario.setBairro(jTextFieldBairro.getText());
            this.funcionario.setCargo(jTextFieldCargo.getText());
            this.funcionario.setCelular(jFormattedTextFieldCelular.getText());
            this.funcionario.setCidade(jTextFieldCidade.getText());
            this.funcionario.setCodigo(Integer.parseInt(jTextFieldCodigo.getText()));
            this.funcionario.setCPF_CNPJ(jFormattedTextFieldCPF.getText(), true);
            this.funcionario.setEmail(jTextFieldEmail.getText());
            this.funcionario.setEstado(jComboBoxEstado.getSelectedIndex());
            this.funcionario.setNome(jTextFieldNome.getText());
            this.funcionario.setNumero(jTextFieldNumero.getText());
            this.funcionario.setPermissao(jCheckBoxVendedor.isSelected());
            this.funcionario.setTelefone(jFormattedTextFieldTelefone.getText());
            this.funcionario.setRua(jTextFieldEndereco.getText());
            this.funcionario.setSalario(Float.parseFloat(jFormattedTextFieldSalario.getText().replace(".", "").replace(",", ".")));


        } catch (SQLException ex) {
            Logger.getLogger(JFrameNovoFuncionario.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NullPointerException ex) {
            Logger.getLogger(JFrameNovoFuncionario.class.getName()).log(Level.SEVERE, null, ex);
        } catch (DinheiroNegativoException ex) {
            Logger.getLogger(JFrameNovoFuncionario.class.getName()).log(Level.SEVERE, null, ex);
        } catch (CpfCnpjExistenteException ex) {
            Logger.getLogger(JFrameNovoFuncionario.class.getName()).log(Level.SEVERE, null, ex);
        } catch (LocalizacaoInvalidaException ex) {
            Logger.getLogger(JFrameNovoFuncionario.class.getName()).log(Level.SEVERE, null, ex);
        } catch (CpfCnpjInvalidoException e) {
        } catch (NomeInvalidoException e) {
        }
        return this.funcionario;
    }

    private void cadastrar() {
        Funcionario novoFuncionario = this.getTextField();
        try {

            BancoFuncionario bf = new BancoFuncionario();
            bf.novo(novoFuncionario);

            Object[] addTable = {novoFuncionario.getCodigo(),
                novoFuncionario.getCPF_CNPJ(),
                novoFuncionario.getNome()};

            JFrameTableEstoque.model.addRow(addTable);

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    private void alterar() {

        try {

            Funcionario novoFuncionario = this.getTextField();
            BancoFuncionario bf = new BancoFuncionario();
            bf.alterar(novoFuncionario);

            Object[] addTable = {novoFuncionario.getCodigo(),
                novoFuncionario.getCPF_CNPJ(),
                novoFuncionario.getNome()};

            JFrameTableCadastroCliente.model.removeRow(this.linhaSelecionada);
            JFrameTableCadastroCliente.model.insertRow(this.linhaSelecionada, addTable);

        } catch (SQLException e) {
        }
    }

    private void initFuncionario() {
        initComponents();
        this.funcionario = new Funcionario();
        try {

            BancoFuncionario bf = new BancoFuncionario();
            int codigo = bf.ultimoFuncionario();

            jTextFieldCodigo.setText("" + (codigo + 1));

        } catch (NullPointerException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (NomeInvalidoException e) {
            e.printStackTrace();
        } catch (CpfCnpjInvalidoException e) {
            e.printStackTrace();
        }
    }

    private void initFuncionario(String cpf) {
        initComponents();

        try {

            BancoFuncionario bf = new BancoFuncionario();
            try {
                this.funcionario = bf.buscar(cpf);
            } catch (DinheiroNegativoException ex) {
                Logger.getLogger(JFrameNovoFuncionario.class.getName()).log(Level.SEVERE, null, ex);
            } catch (CpfCnpjExistenteException ex) {
                Logger.getLogger(JFrameNovoFuncionario.class.getName()).log(Level.SEVERE, null, ex);
            } catch (LocalizacaoInvalidaException ex) {
                Logger.getLogger(JFrameNovoFuncionario.class.getName()).log(Level.SEVERE, null, ex);
            }

            jTextFieldBairro.setText(this.funcionario.getBairro());
            jTextFieldCargo.setText(this.funcionario.getCargo());
            jFormattedTextFieldCelular.setText(this.funcionario.getCelular());
            jTextFieldCidade.setText(this.funcionario.getCidade());
            jTextFieldCodigo.setText("" + this.funcionario.getCodigo());
            jFormattedTextFieldCPF.setText(this.funcionario.getCPF_CNPJ());
            jTextFieldEmail.setText(this.funcionario.getEmail());
            jComboBoxEstado.setSelectedIndex(this.funcionario.getEstado());
            jTextFieldNome.setText(this.funcionario.getNome());
            jTextFieldNumero.setText(this.funcionario.getNumero());
            jCheckBoxVendedor.setSelected(this.funcionario.isPermissao());
            jFormattedTextFieldTelefone.setText(this.funcionario.getTelefone());
            jTextFieldEndereco.setText(this.funcionario.getRua());
            jFormattedTextFieldSalario.setText("" + this.funcionario.getSalario());

        } catch (NullPointerException e) {
        } catch (SQLException e) {
        } catch (NomeInvalidoException e) {
        } catch (CpfCnpjInvalidoException e) {
        }



    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanelInformacoesFuncionario = new javax.swing.JPanel();
        jLabelCodigo = new javax.swing.JLabel();
        jLabelNome = new javax.swing.JLabel();
        jLabelCPF = new javax.swing.JLabel();
        jTextFieldNome = new javax.swing.JTextField();
        jTextFieldCodigo = new javax.swing.JTextField();
        jFormattedTextFieldCPF = new javax.swing.JFormattedTextField();
        jPanelLocalizacao = new javax.swing.JPanel();
        jLabelCidade = new javax.swing.JLabel();
        jLabelEndereco = new javax.swing.JLabel();
        jLabelBairro = new javax.swing.JLabel();
        jTextFieldCidade = new javax.swing.JTextField();
        jTextFieldEndereco = new javax.swing.JTextField();
        jTextFieldBairro = new javax.swing.JTextField();
        jLabelEstado = new javax.swing.JLabel();
        jLabelNumero = new javax.swing.JLabel();
        jComboBoxEstado = new javax.swing.JComboBox();
        jTextFieldNumero = new javax.swing.JTextField();
        jPanelInformacoesAdicionais = new javax.swing.JPanel();
        jLabelTelefone = new javax.swing.JLabel();
        jLabelEmail = new javax.swing.JLabel();
        jLabelCelular = new javax.swing.JLabel();
        jFormattedTextFieldTelefone = new javax.swing.JFormattedTextField();
        jFormattedTextFieldCelular = new javax.swing.JFormattedTextField();
        jTextFieldEmail = new javax.swing.JTextField();
        jButtonCadastrar = new javax.swing.JButton();
        jButtonCancelar = new javax.swing.JButton();
        jPanelInformacoesTrabalhistas = new javax.swing.JPanel();
        jCheckBoxVendedor = new javax.swing.JCheckBox();
        jLabelCargo = new javax.swing.JLabel();
        jLabelSalario = new javax.swing.JLabel();
        jTextFieldCargo = new javax.swing.JTextField();
        jFormattedTextFieldSalario = new javax.swing.JFormattedTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanelInformacoesFuncionario.setBorder(javax.swing.BorderFactory.createTitledBorder("Informações do Funcionário"));

        jLabelCodigo.setText("Código:");

        jLabelNome.setText("Nome:");

        jLabelCPF.setText("CPF:");

        jTextFieldCodigo.setEditable(false);

        try {
            jFormattedTextFieldCPF.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("###.###.###-##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        javax.swing.GroupLayout jPanelInformacoesFuncionarioLayout = new javax.swing.GroupLayout(jPanelInformacoesFuncionario);
        jPanelInformacoesFuncionario.setLayout(jPanelInformacoesFuncionarioLayout);
        jPanelInformacoesFuncionarioLayout.setHorizontalGroup(
            jPanelInformacoesFuncionarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelInformacoesFuncionarioLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelInformacoesFuncionarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabelNome)
                    .addComponent(jLabelCodigo))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelInformacoesFuncionarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanelInformacoesFuncionarioLayout.createSequentialGroup()
                        .addComponent(jTextFieldCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(69, 69, 69)
                        .addComponent(jLabelCPF)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jFormattedTextFieldCPF))
                    .addComponent(jTextFieldNome, javax.swing.GroupLayout.PREFERRED_SIZE, 362, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(36, 36, 36))
        );
        jPanelInformacoesFuncionarioLayout.setVerticalGroup(
            jPanelInformacoesFuncionarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelInformacoesFuncionarioLayout.createSequentialGroup()
                .addGroup(jPanelInformacoesFuncionarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelCPF)
                    .addComponent(jFormattedTextFieldCPF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelCodigo))
                .addGap(18, 18, 18)
                .addGroup(jPanelInformacoesFuncionarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelNome))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanelLocalizacao.setBorder(javax.swing.BorderFactory.createTitledBorder("Localização"));

        jLabelCidade.setText("Cidade:");

        jLabelEndereco.setText("Endereço:");

        jLabelBairro.setText("Bairro:");

        jLabelEstado.setText("Estado:");

        jLabelNumero.setText("Número:");

        jComboBoxEstado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Acre", "Alagoas", "Amapá", "Amazonas", "Bahia", "Ceará", "Distrito Federal", "Espírito Santo", "Goiás", "Maranhão", "Mato Grosso", "Mato Grosso do Sul", "Minas Gerais", "Pará", "Paraíba", "Paraná", "Pernambuco", "Piauí", "Roraima", "Rondônia", "Rio de Janeiro", "Rio Grande do Norte", "Rio Grande do Sul", "Santa Catarina", "São Paulo", "Sergipe", "Tocantins" }));

        javax.swing.GroupLayout jPanelLocalizacaoLayout = new javax.swing.GroupLayout(jPanelLocalizacao);
        jPanelLocalizacao.setLayout(jPanelLocalizacaoLayout);
        jPanelLocalizacaoLayout.setHorizontalGroup(
            jPanelLocalizacaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelLocalizacaoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelLocalizacaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabelBairro)
                    .addComponent(jLabelCidade)
                    .addComponent(jLabelEndereco))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelLocalizacaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jTextFieldCidade)
                    .addComponent(jTextFieldEndereco)
                    .addComponent(jTextFieldBairro, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(32, 32, 32)
                .addGroup(jPanelLocalizacaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabelEstado)
                    .addComponent(jLabelNumero))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelLocalizacaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jTextFieldNumero)
                    .addComponent(jComboBoxEstado, 0, 93, Short.MAX_VALUE))
                .addContainerGap(29, Short.MAX_VALUE))
        );
        jPanelLocalizacaoLayout.setVerticalGroup(
            jPanelLocalizacaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelLocalizacaoLayout.createSequentialGroup()
                .addGroup(jPanelLocalizacaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelLocalizacaoLayout.createSequentialGroup()
                        .addGroup(jPanelLocalizacaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldCidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelCidade))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanelLocalizacaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldEndereco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelEndereco))
                        .addGap(13, 13, 13)
                        .addGroup(jPanelLocalizacaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldBairro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelBairro)))
                    .addGroup(jPanelLocalizacaoLayout.createSequentialGroup()
                        .addGroup(jPanelLocalizacaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelEstado)
                            .addComponent(jComboBoxEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanelLocalizacaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelNumero)
                            .addComponent(jTextFieldNumero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(12, 12, 12))
        );

        jPanelInformacoesAdicionais.setBorder(javax.swing.BorderFactory.createTitledBorder("Informações adicionais"));

        jLabelTelefone.setText("Telefone:");

        jLabelEmail.setText("e-mail:");

        jLabelCelular.setText("Celular:");

        try {
            jFormattedTextFieldTelefone.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(###)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        try {
            jFormattedTextFieldCelular.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(###)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        javax.swing.GroupLayout jPanelInformacoesAdicionaisLayout = new javax.swing.GroupLayout(jPanelInformacoesAdicionais);
        jPanelInformacoesAdicionais.setLayout(jPanelInformacoesAdicionaisLayout);
        jPanelInformacoesAdicionaisLayout.setHorizontalGroup(
            jPanelInformacoesAdicionaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelInformacoesAdicionaisLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelInformacoesAdicionaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabelTelefone)
                    .addComponent(jLabelEmail))
                .addGap(4, 4, 4)
                .addGroup(jPanelInformacoesAdicionaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelInformacoesAdicionaisLayout.createSequentialGroup()
                        .addComponent(jFormattedTextFieldTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(27, 27, 27)
                        .addComponent(jLabelCelular))
                    .addComponent(jTextFieldEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jFormattedTextFieldCelular, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(36, Short.MAX_VALUE))
        );
        jPanelInformacoesAdicionaisLayout.setVerticalGroup(
            jPanelInformacoesAdicionaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelInformacoesAdicionaisLayout.createSequentialGroup()
                .addGroup(jPanelInformacoesAdicionaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelTelefone)
                    .addComponent(jFormattedTextFieldTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelCelular)
                    .addComponent(jFormattedTextFieldCelular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanelInformacoesAdicionaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelEmail))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButtonCadastrar.setText("Cadastrar");
        jButtonCadastrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCadastrarActionPerformed(evt);
            }
        });

        jButtonCancelar.setText("Cancelar");
        jButtonCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCancelarActionPerformed(evt);
            }
        });

        jPanelInformacoesTrabalhistas.setBorder(javax.swing.BorderFactory.createTitledBorder("Informações Trabalhistas"));

        jCheckBoxVendedor.setText("Vendedor");
        jCheckBoxVendedor.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jCheckBoxVendedorMouseClicked(evt);
            }
        });

        jLabelCargo.setText("Cargo:");

        jLabelSalario.setText("Salário:");

        jFormattedTextFieldSalario.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,##0.00"))));
        jFormattedTextFieldSalario.setText("0,00");

        javax.swing.GroupLayout jPanelInformacoesTrabalhistasLayout = new javax.swing.GroupLayout(jPanelInformacoesTrabalhistas);
        jPanelInformacoesTrabalhistas.setLayout(jPanelInformacoesTrabalhistasLayout);
        jPanelInformacoesTrabalhistasLayout.setHorizontalGroup(
            jPanelInformacoesTrabalhistasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelInformacoesTrabalhistasLayout.createSequentialGroup()
                .addGap(16, 16, 16)
                .addComponent(jLabelCargo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextFieldCargo, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(194, Short.MAX_VALUE))
            .addGroup(jPanelInformacoesTrabalhistasLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelSalario)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jFormattedTextFieldSalario, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 153, Short.MAX_VALUE)
                .addComponent(jCheckBoxVendedor)
                .addGap(35, 35, 35))
        );
        jPanelInformacoesTrabalhistasLayout.setVerticalGroup(
            jPanelInformacoesTrabalhistasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelInformacoesTrabalhistasLayout.createSequentialGroup()
                .addGroup(jPanelInformacoesTrabalhistasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelCargo)
                    .addComponent(jTextFieldCargo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelInformacoesTrabalhistasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelSalario)
                    .addComponent(jFormattedTextFieldSalario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jCheckBoxVendedor))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(24, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButtonCancelar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonCadastrar))
                    .addComponent(jPanelInformacoesTrabalhistas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jPanelInformacoesFuncionario, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 489, Short.MAX_VALUE)
                        .addComponent(jPanelInformacoesAdicionais, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanelLocalizacao, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(21, 21, 21))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addComponent(jPanelInformacoesFuncionario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanelLocalizacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanelInformacoesAdicionais, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanelInformacoesTrabalhistas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonCadastrar)
                    .addComponent(jButtonCancelar))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jCheckBoxVendedorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jCheckBoxVendedorMouseClicked
    if (jCheckBoxVendedor.isSelected()) {
        if (this.funcionario.getSenha() == null) {
            new JFrameInserirSenha(this.funcionario).setVisible(true);
        }
    }
}//GEN-LAST:event_jCheckBoxVendedorMouseClicked

private void jButtonCadastrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCadastrarActionPerformed
    if (this.acao.equals("cadastrar")) {
        this.cadastrar();
    } else {
        this.alterar();
    }
    this.setVisible(false);
}//GEN-LAST:event_jButtonCadastrarActionPerformed

private void jButtonCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelarActionPerformed
    this.setVisible(false);
}//GEN-LAST:event_jButtonCancelarActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonCadastrar;
    private javax.swing.JButton jButtonCancelar;
    private javax.swing.JCheckBox jCheckBoxVendedor;
    private javax.swing.JComboBox jComboBoxEstado;
    private javax.swing.JFormattedTextField jFormattedTextFieldCPF;
    private javax.swing.JFormattedTextField jFormattedTextFieldCelular;
    private javax.swing.JFormattedTextField jFormattedTextFieldSalario;
    private javax.swing.JFormattedTextField jFormattedTextFieldTelefone;
    private javax.swing.JLabel jLabelBairro;
    private javax.swing.JLabel jLabelCPF;
    private javax.swing.JLabel jLabelCargo;
    private javax.swing.JLabel jLabelCelular;
    private javax.swing.JLabel jLabelCidade;
    private javax.swing.JLabel jLabelCodigo;
    private javax.swing.JLabel jLabelEmail;
    private javax.swing.JLabel jLabelEndereco;
    private javax.swing.JLabel jLabelEstado;
    private javax.swing.JLabel jLabelNome;
    private javax.swing.JLabel jLabelNumero;
    private javax.swing.JLabel jLabelSalario;
    private javax.swing.JLabel jLabelTelefone;
    private javax.swing.JPanel jPanelInformacoesAdicionais;
    private javax.swing.JPanel jPanelInformacoesFuncionario;
    private javax.swing.JPanel jPanelInformacoesTrabalhistas;
    private javax.swing.JPanel jPanelLocalizacao;
    private javax.swing.JTextField jTextFieldBairro;
    private javax.swing.JTextField jTextFieldCargo;
    private javax.swing.JTextField jTextFieldCidade;
    private javax.swing.JTextField jTextFieldCodigo;
    private javax.swing.JTextField jTextFieldEmail;
    private javax.swing.JTextField jTextFieldEndereco;
    private javax.swing.JTextField jTextFieldNome;
    private javax.swing.JTextField jTextFieldNumero;
    // End of variables declaration//GEN-END:variables
}
